package xyz.xtt.pay.client;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import xyz.xtt.common.response.ApiResult;
import xyz.xtt.pay.api.dto.GetPayStatusMapRequest;
import xyz.xtt.pay.api.dto.GetPayStatusRequest;
import xyz.xtt.pay.api.enums.PayOrderBusinessTypeEnum;
import xyz.xtt.pay.client.request.BusinessOrderRequest;
import xyz.xtt.pay.client.request.ConfirmPayOrderRequest;
import xyz.xtt.pay.client.request.FetchUnPaidOrdersRequest;
import xyz.xtt.pay.client.response.BusinessOrderDto;
import xyz.xtt.pay.client.response.BusinessOrderResponse;
import xyz.xtt.pay.client.response.PayOrderResponse;
import xyz.xtt.pay.client.response.TblPayOrderDto;

@FeignClient(name = "nft-pay", fallbackFactory = PayClientFallbackFactory.class)
public interface PayClient {
	/**
	 * 查询待支付订单
	 * 
	 * @param fetchRequest
	 * @return
	 */
	@PostMapping("/api/nft/pay/order/fetchUnPaid")
	ApiResult<List<TblPayOrderDto>> fetchUnPaidOrders(@RequestBody FetchUnPaidOrdersRequest fetchRequest);

	/**
	 * 支付订单状态确认
	 * 
	 * @param confirmRequest
	 * @return
	 */
	@PostMapping("/api/nft/pay/confirmPayStatus")
	ApiResult<Boolean> confirmPayStatus(@RequestBody @Valid ConfirmPayOrderRequest confirmRequest);

	/**
	 * 获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
	@PostMapping("/api/nft/pay/order/getPayStatus")
	ApiResult<Integer> getPayStatus(@RequestBody @NotNull GetPayStatusRequest request);

	/**
	 * 批量获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
	@PostMapping("/api/nft/pay/order/getPayStatusMap")
	ApiResult<Map<Long, Integer>> getPayStatusMap(@RequestBody @Valid GetPayStatusMapRequest request);

	@GetMapping("/api/nft/pay/order/fetch")
	ApiResult<TblPayOrderDto> fetchPayOrder(@RequestParam(value = "payOrderId") Long payOrderId);

//	@PostMapping("/api/asset/assetCard/getUserCardInfo")
//	ApiResult<List<TblAssetCardDto>> getUserCardInfo(@RequestBody CardInfoRequest cardInfoRequest);

	@PostMapping("/api/nft/pay/businessOrder/selectListByGoodsIds")
	ApiResult<List<BusinessOrderDto>> selectListByGoodsIds(@RequestBody BusinessOrderRequest businessOrderRequest);

	@PostMapping("/api/nft/pay/businessOrder/getByIds")
	ApiResult<Map<Long, BusinessOrderDto>> getBusinessListByIds(@RequestBody Set<Long> ids);

//	@RequestMapping("/api/asset/fund/account/getNeedSettleRecords")
//	ApiResult<List<TblUserFundRecordDto>> getNeedSettleRecords(@RequestParam("maxCount") @Positive Integer maxCount,
//			@RequestParam(value = "lastId", required = false) Long lastId);
//
//	@PostMapping("/api/asset/fund/account/updateFundSettled")
//	ApiResult<Boolean> updateFundSettled(@RequestBody @Valid UpdateFundSettledRequest request);

	@PostMapping("/api/nft/pay/mintAfterUpdateResult")
	ApiResult<Boolean> mintAfterUpdateResult(@RequestParam("payOrderId") Long payOrderId, @RequestParam("transactionOrderId") Long transactionOrderId);

	/**
	 * 查询支付单状态
	 * 
	 * @param businessRefId
	 * @param businessType
	 * @return
	 */
	@GetMapping("/api/nft/pay/queryPayStatus")
	ApiResult<PayOrderResponse> queryPayStatus(@RequestParam("businessRefId") Long businessRefId, @RequestParam("businessType") Integer businessType);

	@GetMapping("/api/nft/pay/businessOrderInfoWithId")
	ApiResult<BusinessOrderResponse> businessOrderInfoWithId(@RequestParam("businessOrderId") Long businessOrderId);

	@GetMapping("/api/nft/pay/order/skipRealPay")
	ApiResult<Boolean> skipRealPay();

	@GetMapping("/api/nft/pay/order/infoPayOrderWithBusinessRefId")
	public ApiResult<PayOrderResponse> infoPayOrderWithBusinessRefId(@RequestParam("businessOrderId") String businessRefId,
			@RequestParam("businessType") PayOrderBusinessTypeEnum businessType);
}
